package com.mc.code.service.Impl;

import com.mc.code.entity.*;
import com.mc.code.mapper.UsersMapper;
import com.mc.code.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class UsersImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public List<CodeUsers> codeUsers(String userNo)
    {
        return  usersMapper.codeUsers(userNo);
    }

    @Override
    public void updateContact(CodeUsers codeUsers) {
        usersMapper.updateContact(codeUsers);
    }

    @Override
    public String nickName(int promulgatorId) {
        return usersMapper.nickname(promulgatorId);
    }

    @Override
    public List<CodeUserId> userId(String userNo) {
        return usersMapper.userId(userNo);
    }

    @Override
    public void updateImage(CodeUsers user) {
        usersMapper.updateImage(user);
    }

    @Override
    public List<CodeSkill> selectSkills() {
        return usersMapper.selectSkills();
    }

    @Override
    public List<Skill> selectGoodSkills(String userNo) {
        return usersMapper.selectGoodSkills(userNo);
    }

    @Override
    public void delSkill(Skill skill) {
        usersMapper.delSkill(skill);
    }

    @Override
    public void insertSkill(Skill skill) {
        usersMapper.insertSkill(skill);
    }

    @Override
    public double selectBanlance(String userNo) {
        return usersMapper.selectBanlance(userNo);
    }

    @Override
    public void recharge(double v,String userNo) {
        usersMapper.recharge(v,userNo);
    }

    @Override
    public int selectPayCondition(String userNo) {
        return usersMapper.selectPayCondition(userNo);
    }

    @Override
    public void updatePsd(String userNo, String psd) {
        usersMapper.updatePsd(userNo,psd);

    }

    @Override
    public String findPsd(String userNo) {
        return usersMapper.findPsd(userNo);
    }

    @Override
    public List<CodeUsers> partakes(Integer itemNo) {
        return usersMapper.partakes(itemNo);
    }

    @Override
    public void updateCondition(Integer itemNo, String partakeNo,Integer partakeCondition) {
        usersMapper.updateCondition(itemNo,partakeNo,partakeCondition);
    }

    @Override
    public void insertUserCard(int userNo, String name, String idNum) {
        usersMapper.insertUserCard(userNo,name,idNum);
    }

    @Override
    public CodeUsers findUserByUserNo(int userNo) {
        return usersMapper.findUserByUserNo(userNo);
    }

    @Override
    public List<userCard> name(String partakeNo) {
        return usersMapper.name(partakeNo);
    }


    @Override
    public String payPsd(String userNo) {
        return usersMapper.payPsd(userNo);
    }

    @Override
    public String getOldPsd(String userNo) {
        return usersMapper.getOldPsd(userNo);
    }

    @Override
    public void pay(int userNo) {
        usersMapper.pay(userNo);
    }


    //————————————————————————————————————————————————————————————后台
    @Override
    public CodeUsers queryByUserNo(int userNo) {
        return usersMapper.queryByUserNo(userNo);
    }

    @Override
    public int deleteCodeUserByUserNo(int userNo) {
        return usersMapper.deleteCodeUserByUserNo(userNo);
    }

    @Override
    public int updateCodeUser(CodeUsers codeUsers) {
        return usersMapper.updateCodeUser(codeUsers);
    }

    @Override
    public int modifyCodeUser(CodeUsers codeUsers) { return usersMapper.modifyCodeUser(codeUsers); }

    @Override
    public List<CodeUsers> queryfaintnessUser(String type,String state,int currentPage, int pageCount) {
        return usersMapper.queryfaintnessUser(type,state,(currentPage - 1) * pageCount,pageCount);
    }

    @Override
    public int getTotalPage(int pageCount,String state ,String type) {
        Integer total =usersMapper.getTotalPage(state,type);
        return (total - 1) / pageCount + 1;
    }

}
